export default {
	data() {
		return {
			userInfo: this.$store.state.login || {},
			type: 0,
			couponList: []
		}
	},
	async onLoad(options) {
		console.log("couponList index onLoad: ", options);
		switch (options.type) {
			case "zhe":
				this.type = 1;
				uni.setNavigationBarTitle({
					title: "我的折扣券"
				});
				await this.getZheCouponList();
				break;
			case "man":
				this.type = 2;
				uni.setNavigationBarTitle({
					title: "我的满减券"
				});
				await this.getManCouponList();
				break;
			default:
				break;
		}
	},
	async onShow() {},
	onHide() {},
	methods: {
		async getZheCouponList() {
			const getRes = await this.$uniCloudCallFunction({
				name: "xxf-coupon",
				action: "getMyZheList",
				data: {
					uid: this.$store.state.login.uid,
				}
			});
			console.log("getRes: ", getRes);
			if (getRes) {
				this.couponList = getRes.list;
			}
		},
		async getManCouponList() {
			const getRes = await this.$uniCloudCallFunction({
				name: "xxf-coupon",
				action: "getMyManList",
				data: {
					uid: this.$store.state.login.uid,
				}
			});
			console.log("getRes: ", getRes);
			if (getRes) {
				this.couponList = getRes.list;
			}
		},
	},
}